{-- 
    when compiling with -O

    > E tests/comp/Issue297.fr:18: Cannot make lambda that has no function type 
    > λv2338 -> mkT id' (mkT id' v2338)  ::  a → a  @@  Lazy<Object>
    
    See 'https://github.com/Frege/frege/issues/297 #297'
-}

module tests.comp.Issue297 where

import frege.Prelude hiding(apply)

main = print $ apply [-1,0,1]

apply :: Show aa => aa -> aa
-- apply = everywhere (\x → mkT id' ( mkT id' x))               -- works!
apply = everywhere (mkT id' . mkT id')                          -- context supplied by typecheck gets lost
      where
          id' :: Int -> Int
          id' = id

everywhere :: (forall a. Show a => a -> a) -> (forall c. Show c => c -> c)
everywhere f = f

mkT :: (Show a, Show b) => (b -> b) -> a -> a
mkT a1 a2 = a2
